//处理用户登录逻辑
const db = require("../lib/db")

function userlogin(username,userpwd){
    //1.用户名不存在
    //2.密码错误
    //3.登录成功
    return new Promise((resolve,reject)=>{
        let sql = "select * from users where userName = '"+username+"'"
        db.querySql(sql).then(data=>{
            if(data.length==0){
                resolve(501)
            }else{
                if(data[0].userpassword == userpwd){
                    resolve(data[0])
                }else{
                    resolve(502)
            }
        }
    })
    })

}
//导出
module.exports = userlogin